<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="../vue.js"></script>

<body>
  <div id="app">
    <my-component>hello

      <template v-slot:second>
        <h1>内部结构</h1>
      </template>

    </my-component>
  </div>

  <template id="first">
    <div>
      <!-- 匿名插槽 -->
      <slot></slot>
      <!-- 具名插槽 -->
      <slot name="second"></slot>
    </div>
  </template>

  <script>
    // 注册组件
    Vue.component("my-component", {
      template: '#first',
    })

    var vm = new Vue({
      el: "#app",
    })

    console.log(vm.$children[0]);
    console.log(vm.$children[0].$slots);
    console.log(vm.$children[0].$slots.second[0]);
    console.log(vm.$children[0].$slots.second[0].children[0]);
    console.log(vm.$children[0].$slots.second[0].children[0].text);
  </script>

</body>

</html>